<!DOCTYPE html>
<html>
<head>
    {include file='public/meta'/}


    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/bootstrap-table/bootstrap-table.css"/>
    <script src="__STATIC_URL__/static/bootstrap-table/bootstrap-table.js"></script>
    <script src="__STATIC_URL__/static/bootstrap-table/bootstrap-table-zh-CN.js"></script>


    <style>
        .layui-laydate {
            z-index: 6666666 !important;
        }
    </style>
</head>
<body>
{include file='public/header'/}
<section id="content">
    <!------------------导航-------------------------->
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content">
        <div class="page-heading mgl15 mgr15">
            <ol class="breadcrumb">
                <li>当前位置是&nbsp;:</li>
                <li><a href="{:url('cards/cardslist')}">卡券管理</a></li>

                <li class="active" style="color: #02b87f;">
                    核销记录
                </li>
            </ol>
        </div>
        <div class="panel panel-default panel-search mgl15 mgr15">
            <div class="panel-heading">
                <h3 class="panel-title">
                    <span class="glyphicon glyphicon-search pull-left" style="margin-right: 10px;"></span>条件查找
                </h3>
            </div>
            <div class="panel-body">
                <form action="" method="get" class="form-horizontal table-search form-search" role="form" id="machform">
                    <div class="col-sm-6 col-md-6 col-lg-4 ">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">核销门店：</label>
                            <div class="col-sm-9">
                                <input type="hidden" name="mchid" id="mach" value="">
                                <input class="form-control" id="mac" style=" display: inline-block;" value="全部门店"
                                       data-target="#myModal3" data-toggle="modal"/>
                            </div>

                        </div>
                    </div>
                    <div class="col-sm-6 col-md-6 col-lg-4 ">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">卡券code：</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" placeholder="请输入卡号" name="code" value="" id="code">
                                <input type="hidden" class="form-control" placeholder="请输入卡号" name="card_id" value="{$card['card_id']}" id="card_id">
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6 col-md-6 col-lg-4 ">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">核销员：</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" placeholder="请输入核销员" name="con_username" value="" id="con_username">
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6 col-md-6 col-lg-4">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">核销时间：</label>
                            <div class="col-sm-9">
                                <div class="input-group">
                                    <div class="">
                                        <input name="search_date" type="text" value="" readonly="readonly"
                                               id="search_date" placeholder="请选择日期" class="form-control" id="search_date">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="panel-footer">
                <a href="javascript:;" class="btn btn-primary" onclick="searchform()">查找</a>
                <a href="javascript:;" class="btn btn-default" onclick="clearform()">清空</a>
            </div>


        </div>

        <div class="panel mgl15 mgr15">
            <div class="panel-heading addCharts" style="background:#ededed;">核销明细</div>
            <div class="panel-body">
                <table class="table table-bordered" id="tablelist">


                </table>
            </div>

        </div>

        {include file='public/footer'/}
    </div>
    <!-- Modal -->
    <div class="modal fade" id="myModal3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document" style="    width: 600px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel3" style="font-size: 16px;">选择门店</h4>

                </div>
                <div class="modal-body">
                    <div class="table-responsive">
                        <table class="table table-bordered">
                            <tr bgcolor="#eee">
                                <th></th>
                                <th>门店</th>

                            </tr>
                            <tbody id="templateHtml3">
                            <tr>
                                <td><input type="checkbox" class="checkAll" name="merch" value="" data-mer="" id="whole"></td>

                                <td>全部门店</td>

                            </tr>
                            {volist name="mach" id="vo"}

                            <tr>
                                <td><input type="checkbox" name="merch" value="{$vo.id}" data-mer="{$vo.merchant}" class="checkSingel"></td>

                                <td>{$vo.merchant}</td>

                            </tr>
                            {/volist}
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" onclick="btn();">确定</button>

                </div>
            </div>
        </div>
    </div>

    <!-- Modal -->
</section>
<script src="__STATIC_URL__/static/laydate/laydate.js"></script>
<script src="/wntable.js"></script>
<script>
    $("#whole").click(function(){
        selectAll();
    })
    function selectAll(){
        // console.log(1);
        // console.log($("#checkall").prop("checked"));
        if ($("#whole").prop("checked")) {
            // console.log(2);
            $("input[type='checkbox'][name='merch']").prop("checked",true);//全选
        } else {
            // console.log(3);
            $("input[type='checkbox'][name='merch']").prop("checked",false);  //取消全选
        }
    }
    $(".checkSingel").click(function () {
        if (this.checked) {

        } else {
            $(".checkAll").prop("checked", false);
        }

    });
</script>
<script>
    function btn(){
        $('#myModal3').modal('hide');

        var tempArray = new Array();
        var merarray= new Array();
        $("input:checkbox[name='merch']:checked").each(function (i) {

            tempArray[i] = $(this).val();
            merarray[i] = $(this).attr("data-mer");
        });

        var val = tempArray.join(',');
        // var mer=merarray.join(',');
        $("#mach").val(val);
        var html="";
        // for (var i = 0; i < merarray.length; i++) {
        //     html+='<span style="display:block">'+merarray[i]+'</span>'
        // }
        $("#mac").val(merarray);
// console.log(val,mer);
    }
</script>
<script>
    function searchform() {
        $("#tablelist" ).bootstrapTable('refresh');
    }
    $(function () {
        var type = "reportcardgenerallist";
        var url = "{:url()}";
        getcolumn(type, url, "tablelist")
    });
    laydate.render({
        elem: '#search_date',
        type: 'date',
        range: true,
        change: function (value, date, date2, data3) {
            var s = value.split(" - ");
            var startdate = new Date(s[0]).getTime();
            var enddate = new Date(s[1]).getTime();
            var ldate = Math.floor((enddate - startdate) / (24 * 3600 * 1000));
            if (ldate > 31) {
                layer.alert("日期区间不能大于31天");
                $("#search_date").val("");
            }
        }
    });
</script>
</body>
</html>
